//
//  GuanFangActivityDetailViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/7.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "GuanFangActivityDetailViewController.h"
#import "PingLunOfGuanFangActivityViewController.h"

@interface GuanFangActivityDetailViewController ()

@property (nonatomic, strong) UIScrollView *backGroundScrollview; // 背景
@property (nonatomic, strong) UIImageView *topImageV; // 顶部图片
@property (nonatomic, strong) UILabel *joinMemberCount; // 参加人数
@property (nonatomic, strong) UILabel *startTimeLabel; // 开始时间
@property (nonatomic, strong) UILabel *endTimeLabel; // 结束时间
@property (nonatomic, strong) UILabel *contentIntroduceLabel; // 内容介绍


@end

@implementation GuanFangActivityDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // navi的修改
    [self changeNavigation];
    // 布局
    [self addMySubview];
}

// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = @"官方活动列表";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
    UIImageView *rightImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    rightImageView.image = [UIImage imageNamed:@"fenxiang"];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightImageView];
    UITapGestureRecognizer *rightTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(share:)];
    [rightImageView addGestureRecognizer:rightTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 分享
- (void)share:(UITapGestureRecognizer *)tapGes
{
    NSLog(@"分享");
}

#pragma mark - 布局
- (void)addMySubview
{
    self.backGroundScrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 100 * kAdjustParamater)];
    self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, kScreenHeight);
    self.backGroundScrollview.backgroundColor = [UIColor whiteColor];
    self.backGroundScrollview.bounces = NO;
    self.backGroundScrollview.scrollEnabled = YES;
    self.backGroundScrollview.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_backGroundScrollview];
    
    // 顶部图片
    self.topImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 150 * kAdjustParamater)];
    self.topImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [self.backGroundScrollview addSubview:_topImageV];
    
    // 中间白色背景
    UIView *whiteViewInMiddle = [[UIView alloc] initWithFrame:CGRectMake(0, self.topImageV.bottom, kScreenWidth, 85 * kAdjustParamater)];
    whiteViewInMiddle.backgroundColor = [UIColor whiteColor];
    [self.backGroundScrollview addSubview:whiteViewInMiddle];
    
    // 闹钟
    UIImageView *alertView = [[UIImageView alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 13 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
    alertView.image = [UIImage imageNamed:@"naozhong-guanfang"];
  //  alertView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [whiteViewInMiddle addSubview:alertView];
    
    // 活动时间
    UILabel *activityTime = [[UILabel alloc] initWithFrame:CGRectMake(alertView.right + 8 * kAdjustParamater, 18 * kAdjustParamater, 100 * kAdjustParamater, 15 * kAdjustParamater)];
 //   activityTime.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    activityTime.text = @"活动时间";
    activityTime.textAlignment = NSTextAlignmentLeft;
    activityTime.textColor = [UIColor blackColor];
    activityTime.font = [UIFont systemFontOfSize:k15Big];
    [whiteViewInMiddle addSubview:activityTime];
    
    // 头像
    UIImageView *peopleImageV = [[UIImageView alloc] initWithFrame:CGRectMake(250 * kAdjustParamater, 17 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
    peopleImageV.image = [UIImage imageNamed:@"小人-01"];
 //   peopleImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [whiteViewInMiddle addSubview:peopleImageV];
    
    // 参加人数
    self.joinMemberCount = [[UILabel alloc] initWithFrame:CGRectMake(peopleImageV.right + 7 * kAdjustParamater, 18 * kAdjustParamater, 100 * kAdjustParamater, 14 * kAdjustParamater)];
    self.joinMemberCount.text = [NSString stringWithFormat:@"2193452 人参加"];
    self.joinMemberCount.textColor = kYellowColor;
    self.joinMemberCount.textAlignment = NSTextAlignmentLeft;
    self.joinMemberCount.font = [UIFont systemFontOfSize:k12Big];
 //   self.joinMemberCount.backgroundColor =[[UIColor blackColor] colorWithAlphaComponent:0.1];
    [whiteViewInMiddle addSubview:_joinMemberCount];
    
    // 开始时间
    self.startTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(23 * kAdjustParamater, alertView.bottom + 14 * kAdjustParamater, 90 * kAdjustParamater, 20 * kAdjustParamater)];
   // self.startTimeLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    self.startTimeLabel.text = @"2016-03-01";
    self.startTimeLabel.textColor = [UIColor redColor];
    self.startTimeLabel.font = [UIFont systemFontOfSize:k16Big];
    self.startTimeLabel.textAlignment = NSTextAlignmentRight;
    [whiteViewInMiddle addSubview:_startTimeLabel];
    
    // 至
    UILabel *zhiLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.startTimeLabel.right + 6 * kAdjustParamater, self.startTimeLabel.top, 20 * kAdjustParamater, 20 * kAdjustParamater)];
   // zhiLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    zhiLabel.text = @"至";
    zhiLabel.textColor = [UIColor blackColor];
    zhiLabel.font = [UIFont systemFontOfSize:k16Big];
    [whiteViewInMiddle addSubview:zhiLabel];
    
    // 结束时间
    self.endTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(zhiLabel.right + 6 * kAdjustParamater, zhiLabel.top, 90 * kAdjustParamater, 20 * kAdjustParamater)];
  //  self.endTimeLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    self.endTimeLabel.text = @"2016-04-01";
    self.endTimeLabel.textColor = [UIColor redColor];
    self.endTimeLabel.font = [UIFont systemFontOfSize:k16Big];
    self.endTimeLabel.textAlignment = NSTextAlignmentLeft;
    [whiteViewInMiddle addSubview:_endTimeLabel];
    
    // 灰色条
    UILabel *grayLineOnWhiteMiddle = [[UILabel alloc] initWithFrame:CGRectMake(0, whiteViewInMiddle.bottom, kScreenWidth, 20 * kAdjustParamater)];
    grayLineOnWhiteMiddle.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.03];
    [self.backGroundScrollview addSubview:grayLineOnWhiteMiddle];
    
    // 喇叭
    UIImageView *labaImageV = [[UIImageView alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, grayLineOnWhiteMiddle.bottom  + 13 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
    labaImageV.image = [UIImage imageNamed:@"laba-guanfang"];
  //  labaImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [self.backGroundScrollview addSubview:labaImageV];
    
    // 活动介绍
    UILabel *activityIntroduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(labaImageV.right + 8 * kAdjustParamater, grayLineOnWhiteMiddle.bottom + 18 * kAdjustParamater, 100 * kAdjustParamater, 15 * kAdjustParamater)];
 //   activityIntroduceLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    activityIntroduceLabel.text = @"活动介绍";
    activityIntroduceLabel.textAlignment = NSTextAlignmentLeft;
    activityIntroduceLabel.textColor = [UIColor blackColor];
    activityIntroduceLabel.font = [UIFont systemFontOfSize:k15Big];
    [self.backGroundScrollview addSubview:activityIntroduceLabel];
    
    // 正文介绍
    self.contentIntroduceLabel = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, labaImageV.bottom + 15 * kAdjustParamater, kScreenWidth - 40 * kAdjustParamater, 100 * kAdjustParamater)];
    self.contentIntroduceLabel.numberOfLines = 0;
    self.contentIntroduceLabel.text = @"染色体的主要化学成份是脱氧核糖核酸（DNA）和蛋白质构成，染色体上的蛋白质有两类：一类是低分子量的碱性蛋白质即组蛋白（histones），另一类是酸性蛋白质，即非组蛋白蛋白质（non-histone proteins）。非组蛋白蛋白质的种类和含量不十分恒定，而组蛋白的种类和含量都很恒定，其含量大致与DNA相等。所以人们早就猜测，组蛋白在DNA·蛋白质纤丝的形成上起着重要作用。Kornberg根据生化资料，特别是根据电镜照相，最先在1974年提出绳珠模型（beads on－a－string model），用来说明DNA·蛋白质纤丝的结构。纤丝的结构单位是核小体，它是染色体结构的最基本单位。核小体的核心是由4种组蛋白（H2A、H2B、H3和H4）各两个分子构成的扁球状8聚体。我们知道，DNA分子具有典型的双螺旋结，一个DNA分子就像是一条长长的双螺旋的纤丝。一条染色体有一个DNA分子。DNA双螺旋依次在每个组蛋白8聚体分子的表面盘绕约1.75圈，其长度相当于140个碱基对。组蛋白8聚体与其表面上盘绕的DNA分子共同构成核小体。在相邻的两个核小体之间，有长约50～60个碱基对的DNA连接线。在相邻的连接线之间结合着一个第5种组蛋白（H1）的分子。密集成串的核小体形成了核质中的100埃左右的纤维，这就是染色体的“一级结构”，就像成串的珠子一样，DNA为绳，组蛋白为珠，被称作染色体的“绳珠模型”如图→在这里，DNA分子大约被压缩了7倍。";
    self.contentIntroduceLabel.textColor = [UIColor blackColor];
    self.contentIntroduceLabel.backgroundColor = [[UIColor yellowColor] colorWithAlphaComponent:0.2];
    self.contentIntroduceLabel.font = [UIFont systemFontOfSize:k13Big];
    [self.backGroundScrollview addSubview:_contentIntroduceLabel];
    
    CGRect newFrame = self.contentIntroduceLabel.frame;
    newFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:self.contentIntroduceLabel.text size:13 width:335];
    self.contentIntroduceLabel.frame = newFrame;
    
    UILabel *grayLabelOnContentBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, self.contentIntroduceLabel.bottom + 10 * kAdjustParamater, kScreenWidth, 20 * kAdjustParamater)];
    grayLabelOnContentBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.03];
    [self.backGroundScrollview addSubview:grayLabelOnContentBottom];

    CGRect scrollFrame = self.backGroundScrollview.frame;
    scrollFrame.size.height = grayLabelOnContentBottom.bottom + 100 * kAdjustParamater;
    self.backGroundScrollview.frame = scrollFrame;
    NSLog(@"height = %f", self.backGroundScrollview.frame.size.height);
    self.backGroundScrollview.contentSize = CGSizeMake(kScreenWidth, self.backGroundScrollview.frame.size.height + 120 * kAdjustParamater);
    
    // 底部白色背景
    UIView *whiteViewOnScreenBottom = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight - 64 - 60 * kAdjustParamater, kScreenWidth, 60 * kAdjustParamater)];
    whiteViewOnScreenBottom.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:whiteViewOnScreenBottom];
    
    // 灰色条
    UILabel *grayLineOnWhiteTop = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 2 * kAdjustParamater)];
    grayLineOnWhiteTop.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [whiteViewOnScreenBottom addSubview:grayLineOnWhiteTop];
    
    // 报名
    UIButton *baoMingButton = [[UIButton alloc] initWithFrame:CGRectMake(55 * kAdjustParamater, 15 * kAdjustParamater, 110 * kAdjustParamater, 30 * kAdjustParamater)];
    baoMingButton.backgroundColor = kCyanColor;
    [baoMingButton setTitle:@"我要报名" forState:UIControlStateNormal];
    [baoMingButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    baoMingButton.titleLabel.font = [UIFont systemFontOfSize:k19Big];
    baoMingButton.layer.cornerRadius = 5 * kAdjustParamater;
    [baoMingButton addTarget:self action:@selector(baoMing:) forControlEvents:UIControlEventTouchUpInside];
    [whiteViewOnScreenBottom addSubview:baoMingButton];
    
    // 评论
    UIButton *pingLunButton = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth - 165 * kAdjustParamater, 15 * kAdjustParamater, 110 * kAdjustParamater, 30 * kAdjustParamater)];
    pingLunButton.backgroundColor = kCyanColor;
    [pingLunButton setTitle:@"评论界面" forState:UIControlStateNormal];
    [pingLunButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    pingLunButton.titleLabel.font = [UIFont systemFontOfSize:k19Big];
    pingLunButton.layer.cornerRadius = 5 * kAdjustParamater;
    [pingLunButton addTarget:self action:@selector(pingLun:) forControlEvents:UIControlEventTouchUpInside];
    [whiteViewOnScreenBottom addSubview:pingLunButton];

}

#pragma mark - 报名
- (void)baoMing:(UIButton *)button
{
    NSLog(@"报名");
}

#pragma mark - 评论
- (void)pingLun:(UIButton *)button
{
    NSLog(@"评论");
    PingLunOfGuanFangActivityViewController *pingLunOfGuanFangActivityVC = [[PingLunOfGuanFangActivityViewController alloc] init];
    [self.navigationController pushViewController:pingLunOfGuanFangActivityVC animated:YES];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
